package dungeon;

import basicPackage.Coordinate;


/**
 * A class representing a level containing squares under their respective coordinates.
 * 
 * @invar	| getMaxCoordinate != null
 * @invar	| getMaxCoordinate().isPositive
 * @invar	| getMaxCoordinate().getZ() == 0
 * @invar	| if(getSuperCompositedungeon != null)
 * 			|	getMaxCoordinate().add(getDungeonCoordinate()).isSmallerOrEqualTo(getSuperCompositeDungeon().geMaxCoordinate
 * @invar	| getSuperCompositeDungeon() != this
 * @invar	| (getDungeonCoordinate() == null || getDungeonCoordinate().isPositive())
 * @invar	| if(containsElementCoordinate(coordinate)
 * 			|	coordinate.isPositive && coordinate.isSmallerOrEqualTo(getMaxCoordinate()) && !coordinate.hasSameValueForAllCoordinates()
 * @invar	| if( exists coordinate: getElement(coordinate) != null)
 * 			|	exists no coordinate2: coordinate2 != coordinate && getElement(coordinate) == getElement(coordinate2)
 * @invar	| if( exists element: exists coordinate: getElement(coordinate) == element))
 * 			|	exists no element2: element2 != element: getElement(coordinate) == element2
 * @invar	| if( exists coordinate: getSquare(coordinate) != null)
 * 			|	exists no coordinate2: coordinate2 != coordinate && getSquare(coordinate) == getSquare(coordinate2)
 * @invar	| if( exists square: exists coordinate: getSquare(coordinate) == square))
 * 			|	exists no square2: square != square2: getSquare(coordinate) == square2
 * @invar	| if(containsSquareCoordinate(coordinate))
 * 			|	for each Direction.i: containsSquareCoordinate(coordinate.getNeighboringCoordinates().get(i))
 * 			|		getSquare(coordinate).getBorderingSquare(i) == getSquare(coordinate.getNeighboringCoordinates().get(i))
 * 			|		getSquare(coordinate.getNeighboringCoordinates().get(i)).getBorderingSquare(i.oppositeDirection()) == getSquare(coordinate)
 * 
 * @author Laurens Vanderstraeten
 */
public class Level<S extends Square> extends SquareDungeon<S>{

	/**
	 * Construct a level.
	 * 
	 * @param 	maxCoordinate
	 * 			The maximum coordinate determining the outer point in the cuboid space of 
	 * 			possible square coordinates.
	 * @post	| getMaxCoordinate() == maxCoordinate
	 * @throws	IllegalArgumentException
	 * 			| !isValidMaxCoordinate(maxCoordinate)
	 */
	public Level(Coordinate maxSquareCoordinate) {
		super(maxSquareCoordinate);
	}

	/**
	 * Check whether the given coordinate is a valid maximum coordinate.
	 * 
	 * @param 	coordinate
	 * 			The coordinate to be checked.
	 * @return	| if(coordinate == null)
	 *			|	result == false
	 *			| if(!coordinate.isPositive())
	 *			|	result == false
	 *			| if(!coordinate.isLargerOrEqualTo(getMaxCoordinate()))
	 *			|	result == false
	 *			| if(getSuperCompositeDungeon() != null && !coordinate.add(getDungeonCoordinate()).isSmallerOrEqualTo(getSuperCompositeDungeon().getMaxCoordinate()))
	 *			|	result == false
	 *			| if(coordinate.getZ() != 0)
	 *			|	result == false
	 *			| else then
	 *			|	result == true
	 */
	@Override
	public Boolean isValidMaxCoordinate(Coordinate coordinate) {
		if(!super.isValidMaxCoordinate(coordinate))
			return false;
		if(coordinate.getZ() != 0)
			return false;
		return true;
	}
}
